package org.casper.mbean;

import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;

import com.sun.jdmk.comm.HtmlAdaptorServer;

public class Main {
	private static ObjectName objectName ; 
	private static MBeanServer mBeanServer; 
	
	/**
	 *  -Dcom.sun.management.jmxremote
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception{ 
		//获取mbean的服务器
		mBeanServer = MBeanServerFactory.createMBeanServer();
		
		ServerImpl serverImpl = new ServerImpl(); 
		ServerMonitor serverMonitor = new ServerMonitor(serverImpl); 
		objectName = new ObjectName("objectName:id=ServerMonitor1");
		//注册mbean
		mBeanServer.registerMBean(serverMonitor, objectName);
		
		ObjectName adapterName = new ObjectName("Main:name=htmladapter,port=8082");
		HtmlAdaptorServer adaptorServer = new HtmlAdaptorServer();
	    mBeanServer.registerMBean(adaptorServer,adapterName);
	 
	    adaptorServer.start();
	}
}
